#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
using namespace std;
int ans; int n, k;
int arr[50];
int judge(int digit)
{
	for (int i = 2; i * i <= digit; i++) {
		if (digit % i == 0)return 0;
	}
	return 1;
}
void fun(int m,int ws,int sum)
{
	if (m == 0 ) {
		if (judge(sum))
			ans++;
		return;
	}
	if (ws >= n)return;
	for (int i = ws; i < n; i++) {
		fun(m - 1, i + 1, sum + arr[i]);
	}
}
int main()
{
	int ws = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	fun(k, ws, 0);
	cout << ans;
	return 0;
}